/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package org.whu.weibo_souhu.login;

import java.io.IOException;
import java.util.HashMap;
import org.apache.http.client.params.CookiePolicy;
import org.apache.http.HttpResponse;
import org.apache.http.Header;
import org.apache.http.client.params.HttpClientParams;
import org.apache.http.impl.client.DefaultHttpClient;
import org.apache.http.client.HttpClient;
import org.apache.http.client.methods.HttpGet;
import java.util.Date;
import java.net.URLEncoder;

/**
 *
 * @author Administrator
 */
public class test {
    public static void main(String[] agrs) throws IOException
    {
         long servertime = new Date().getTime() / 1;
            String.valueOf(servertime);
            String su = URLEncoder.encode("guo.guowww@163.com");
        HashMap hm=new HashMap();
        HttpClient httpclient=new DefaultHttpClient();
        HttpClientParams.setCookiePolicy(httpclient.getParams(), CookiePolicy.BROWSER_COMPATIBILITY);  //设置兼容性
  //      httpclient.getParams().setParameter(CoreConnectionPNames.CONNECTION_TIMEOUT,1000); //设置连接时限。请求时间
    //    httpclient.getParams().setParameter(CoreConnectionPNames.SO_TIMEOUT, 1000); //设置读取时间
        HttpGet httpget=new HttpGet("http://t.sohu.com/new_index");
        HttpResponse response=httpclient.execute(httpget);
        if(response.getStatusLine().getStatusCode()==200)
        {
            Header[] header=response.getHeaders("Set-Cookie");
            String params=new String();
            String value=new String();
            for(Header h:header)
            {
                params=h.getValue().substring(0,h.getValue().indexOf("="));
                value=h.getValue().substring(h.getValue().indexOf("=")+1,h.getValue().indexOf(";"));
                hm.put(params,value);
            }
           
               
        }
        
    }
    
    
}
